#include<bits/stdc++.h>
using namespace std;
mt19937_64 Rnd(time(0));
unsigned long long a[65];
const unsigned long long inf = (0ull - 1ull);
bool Check(unsigned long long x)
{
	for(int i = 63;i >= 0;i--) if(x & (1ull << i))
	{
		if(!a[i])
			return a[i] = x;
		else
			x ^= a[i];
	}
	return 0;
}
int n,m,q;
pair<int,int> e[200011];
vector<pair<int,int> > v[200011];
unsigned long long w[200011],xr[200011];
bool vis[200011];
void DFS(int p)
{
	vis[p] = 1;
	for(auto i:v[p]) if(!vis[i.second])
		DFS(i.second),w[i.first] ^= (inf ^ xr[i.second]),xr[p] ^= xr[i.second];
}
vector<int> qs[100011];
bool ans[100011];//1:connacted
int T = 1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("graph.in","r",stdin);
	freopen("graph.out","w",stdout);
	cin >> n >> m;
	for(int i = 1;i <= m;i++)
		cin >> e[i].first >> e[i].second,v[e[i].first].push_back({i,e[i].second}),v[e[i].second].push_back({i,e[i].first});
	cin >> q;
	for(int i = 1;i <= q;i++)
	{
		int k;
		cin >> k;
		while(k--)
		{
			int x;
			cin >> x;
			qs[i].push_back(x);
		}
	}
	while(T--)
	{
		for(int i = 1;i <= n;i++)
			xr[i] = vis[i] = 0;
		for(int i = 1;i <= m;i++)
			w[i] = Rnd(),xr[e[i].first] ^= w[i],xr[e[i].second] ^= w[i];
		DFS(1);
		for(int i = 1;i <= q;i++) if(!ans[i])
		{
			memset(a,0,sizeof(a));
			for(auto x:qs[i])
				Check(w[x]);
			ans[i] |= Check(inf);
		}
	}
	for(int i = 1;i <= q;i++)
		cout << (ans[i] ? "YES\n" : "NO\n");
	return 0;
}
